home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Files
/
Locations
/
Directory.cp
< prev
next >
Wrap
Text File
|
2000-06-23
|
1KB
|
67 lines
// Directory.cp
#ifndef Directory_h
#include "Directory.h"
#endif
#ifndef CatInfo_h
#include "CatInfo.h"
#endif
#ifndef NotADirectoryError_h
#include "NotADirectoryError.h"
#endif
#ifndef DirectoryNotFoundError_h
#include "DirectoryNotFoundError.h"
#endif
#include <Errors.h>
void Directory::Up()
{
Assert( !IsRoot() );
CatInfo info( *this );
id = info.Location().ParentID();
}
void Directory::Down( ConstPString name )
{
CatInfo info( *this, name );
if ( !info.IsDirectory() )
throw NotADirectoryError( noErr );
volume = info.Location().Volume();
id = info.Directory().ID();
}
Directory Directory::Parent() const
{
Assert( !IsRoot() );
CatInfo info( *this );
return info.Location().Parent();
}
Directory Directory::FindSpecialFolder( OSType folder,
::Volume volume,
bool canCreate )
{
int16 volumeFound;
int32 directoryFound;
OSErr error = FindFolder( volume.RefNum(),
folder,
canCreate,
&volumeFound,
&directoryFound );
switch ( error )
{
case fnfErr: throw DirectoryNotFoundError( error );
case dupFNErr: throw NotADirectoryError( error );
}
if ( error != noErr )
throw FileError( error );
return Directory( ::Volume( volumeFound ),
DirectoryID( directoryFound ) );
}